<template>
  <div :id="id" :ref="id" :style="{height: height}"></div>
</template>
<script>
export default {
  props: {
    height: {
      type: String,
      default: '150px'
    },
    id: String,
    option: Object
  },
  data(){
    return {
      chart: null,
    }
  },
  mounted() {
    this.chart = this.$echarts.init(this.$refs[this.id]);
    this.chart.setOption(this.option);
  },
  watch: {
    option: {
      handler(){
        this.chart.clear();
        this.chart.setOption(this.option);
      },
      deep: true
    }
  }
}
</script>
